#include "Directions.h"
#include <cstdlib>

void randomDirections(Vector normal, int numberOfDirections, vector<Vector>& result)
{
    /*
    for (int i = 0; i < numberOfDirections; i++) {
        Vector aux = directions320(i);

        if (normal * aux < 0) result.push_back(-1*aux);
        else  result.push_back(aux);
    }
    /**/
    srand(0);
    int start = rand();
    vector<Vector> discarded;
    for (unsigned int i = 0; i < 320; i++) {
        Vector aux = directions320((start + i) % 320);
        if (normal * aux > 0) {
            result.push_back(aux);
            if (result.size() == numberOfDirections)
                return;
        }
        else {
            discarded.push_back(aux);
        }
    }
    for (unsigned int i = 0; i < discarded.size(); i++) {
        result.push_back(-1 * discarded[i]);
        if (result.size() == numberOfDirections)
            return;
    }

}


Vector directions320(int i)
{
    static Vector dirs[320]= {
        Vector( -0.757336f, -0.555467f, -0.343363f),
        Vector( -0.176875f, -0.744036f, 0.644303f),
        Vector( -0.0000000360737f, 0.987544f, -0.157343f),
        Vector( -0.886927f, 0.45517f, -0.0786233f),
        Vector( -0.400773f, 0.0367587f, -0.91544f),
        Vector( -0.580429f, 0.497973f, 0.644302f),
        Vector( -0.559113f, 0.769556f, 0.308505f),
        Vector( -0.345837f, 0.205829f, -0.91544f),
        Vector( 0.904654f, 0.144423f, -0.400927f),
        Vector( 0.0888857f, 0.392517f, -0.91544f),
        Vector( 0.816753f, 0.172975f, -0.55045f),
        Vector( -0.14734f, -0.791177f, -0.593574f),
        Vector( -0.584244f, -0.55347f, 0.593574f),
        Vector( 0.449966f, 0.468103f, 0.760533f),
        Vector( 0.757336f, 0.555467f, 0.343363f),
        Vector( 0.448244f, -0.313715f, -0.837054f),
        Vector( -0.436877f, 0.329362f, -0.837054f),
        Vector( 0.436878f, -0.601311f, 0.669001f),
        Vector( -0.159859f, -0.98268f, -0.0937297f),
        Vector( -0.302646f, 0.937435f, -0.172106f),
        Vector( 0.706933f, -0.701043f, 0.0937296f),
        Vector( -0.159846f, 0.52325f, 0.837054f),
        Vector( 0.904654f, -0.144423f, 0.400927f),
        Vector( -0.580463f, -0.79894f, -0.157343f),
        Vector( -0.886927f, -0.45517f, 0.0786233f),
        Vector( -0.639173f, -0.11422f, 0.760533f),
        Vector( -0.147345f, -0.884659f, -0.442343f),
        Vector( -0.639174f, 0.114219f, -0.760534f),
        Vector( -0.0888857f, 0.392517f, -0.91544f),
        Vector( -0.983983f, 0.15163f, 0.0937297f),
        Vector( 0.0000000564056f, -0.607016f, -0.794689f),
        Vector( 0.14734f, 0.791177f, 0.593574f),
        Vector( 0.58424f, -0.283291f, 0.760533f),
        Vector( 0.400773f, 0.036759f, -0.91544f),
        Vector( -0.934166f, 0.303529f, 0.187625f),
        Vector( -0.176875f, 0.744036f, -0.644303f),
        Vector( -0.70697f, 0.70286f, 0.0786233f),
        Vector( -0.639194f, -0.629097f, 0.442344f),
        Vector( -0.904654f, -0.144423f, 0.400927f),
        Vector( 0.54706f, -0.752967f, 0.36574f),
        Vector( -0.000000056406f, 0.982241f, 0.187625f),
        Vector( -0.584244f, 0.55347f, -0.593574f),
        Vector( 0.345837f, -0.205829f, 0.91544f),
        Vector( 0.158818f, -0.984172f, 0.0786233f),
        Vector( -0.58424f, 0.283291f, -0.760533f),
        Vector( 0.4169f, 0.723326f, 0.550449f),
        Vector( 0.795829f, 0.413509f, 0.442343f),
        Vector( -0.4169f, 0.723326f, 0.550449f),
        Vector( -0.0000000641764f, 0.930717f, 0.36574f),
        Vector( -0.294237f, -0.705903f, -0.644303f),
        Vector( 0.706923f, 0.384617f, 0.593573f),
        Vector( -0.436877f, -0.329362f, 0.837054f),
        Vector( 0.577307f, 0.187578f, 0.79469f),
        Vector( 0.904667f, 0.293944f, -0.308505f),
        Vector( -0.176874f, 0.243446f, -0.953651f),
        Vector( 0.559093f, 0.620016f, 0.55045f),
        Vector( 0.17824f, 0.517273f, -0.837054f),
        Vector( -0.985077f, 0.00184962f, -0.172107f),
        Vector( -0.158818f, -0.984172f, 0.0786233f),
        Vector( 0.306164f, -0.936292f, -0.172106f),
        Vector( 0.400773f, -0.0367587f, 0.91544f),
        Vector( -0.652962f, 0.398139f, -0.644302f),
        Vector( -0.294237f, 0.705903f, 0.644303f),
        Vector( 0.81677f, -0.414903f, 0.400927f),
        Vector( 0.706884f, 0.229681f, 0.669001f),
        Vector( -0.08788f, -0.120956f, 0.98876f),
        Vector( 0.797984f, -0.104358f, -0.593574f),
        Vector( -0.345837f, -0.20583f, 0.91544f),
        Vector( 0.58424f, 0.283291f, -0.760533f),
        Vector( 0.985077f, 0.00184979f, -0.172107f),
        Vector( -0.64699f, -0.648584f, -0.400927f),
        Vector( -0.449966f, -0.468103f, -0.760533f),
        Vector( 0.142193f, 0.0462013f, 0.98876f),
        Vector( 0.54706f, 0.752967f, -0.36574f),
        Vector( 0.795857f, 0.58051f, 0.172107f),
        Vector( 0.985081f, -0.153081f, 0.0786234f),
        Vector( -0.448244f, -0.313715f, -0.837054f),
        Vector( 0.436878f, 0.601311f, -0.669001f),
        Vector( -0.449996f, -0.889563f, -0.0786233f),
        Vector( -0.76231f, -0.54862f, 0.343364f),
        Vector( -0.176874f, -0.243446f, 0.953651f),
        Vector( 0.559113f, -0.769556f, -0.308505f),
        Vector( 0.983983f, 0.15163f, 0.0937293f),
        Vector( 0.706923f, -0.384617f, -0.593573f),
        Vector( 0.142193f, -0.0462013f, -0.98876f),
        Vector( -0.706923f, -0.384617f, -0.593573f),
        Vector( 0.64699f, -0.648584f, -0.400927f),
        Vector( -0.54706f, 0.752967f, -0.36574f),
        Vector( 0.577346f, -0.79465f, 0.187625f),
        Vector( 0.159846f, 0.52325f, 0.837054f),
        Vector( -0.547034f, -0.00967031f, -0.837054f),
        Vector( 0.176874f, -0.243446f, 0.953651f),
        Vector( -0.798031f, 0.577517f, -0.172107f),
        Vector( -0.159859f, 0.98268f, 0.0937297f),
        Vector( -0.706923f, 0.384617f, 0.593573f),
        Vector( -0.08788f, 0.120956f, -0.98876f),
        Vector( 0.142199f, 0.905007f, -0.400927f),
        Vector( 0.762439f, -0.340136f, 0.550449f),
        Vector( 0.087881f, -0.83023f, 0.55045f),
        Vector( 0.584244f, 0.55347f, -0.593574f),
        Vector( 0.934166f, 0.303529f, 0.187625f),
        Vector( 0.448277f, 0.888967f, -0.0937294f),
        Vector( -0.985081f, -0.153081f, 0.0786234f),
        Vector( 0.580429f, 0.497973f, 0.644302f),
        Vector( 0.436877f, -0.329362f, 0.837054f),
        Vector( 0.087881f, 0.83023f, -0.55045f),
        Vector( -0.547034f, 0.00967021f, 0.837054f),
        Vector( -0.302625f, -0.265307f, -0.91544f),
        Vector( 0.449996f, -0.889563f, -0.0786233f),
        Vector( -0.797984f, 0.104358f, 0.593574f),
        Vector( 0.559113f, 0.769556f, 0.308505f),
        Vector( 0.29425f, 0.891919f, 0.343363f),
        Vector( 0.34584f, 0.726681f, -0.593574f),
        Vector( -0.448277f, -0.888967f, 0.0937294f),
        Vector( -0.939193f, 0.0042307f, -0.343363f),
        Vector( 0.400783f, -0.802313f, 0.442343f),
        Vector( -0.0000000310314f, 0.300916f, 0.953651f),
        Vector( -0.0888857f, -0.392517f, 0.91544f),
        Vector( -0.762439f, 0.340136f, -0.550449f),
        Vector( 0.147345f, 0.884659f, 0.442343f),
        Vector( 0.795829f, -0.413509f, -0.442343f),
        Vector( 0.706968f, 0.702862f, 0.0786235f),
        Vector( -0.17824f, -0.517273f, 0.837054f),
        Vector( -0.087881f, -0.83023f, 0.55045f),
        Vector( -0.93921f, 0.305168f, -0.157343f),
        Vector( -0.0888863f, -0.643186f, 0.760533f),
        Vector( 0.76231f, -0.54862f, 0.343364f),
        Vector( 0.885185f, -0.455701f, -0.0937298f),
        Vector( 0.580463f, 0.79894f, 0.157343f),
        Vector( 0.0000000641764f, -0.930717f, -0.36574f),
        Vector( -0.798031f, -0.577517f, 0.172107f),
        Vector( 0.142199f, -0.905007f, 0.400927f),
        Vector( 0.580463f, -0.79894f, -0.157343f),
        Vector( -0.0000000151172f, 0.14951f, 0.98876f),
        Vector( -0.577346f, -0.79465f, 0.187625f),
        Vector( 0.416907f, -0.815748f, -0.400927f),
        Vector( 0.159859f, 0.98268f, 0.0937297f),
        Vector( 0.4169f, -0.723326f, -0.550449f),
        Vector( 0.159859f, -0.98268f, -0.0937297f),
        Vector( -0.795829f, -0.413509f, -0.442343f),
        Vector( -0.559113f, -0.769556f, -0.308505f),
        Vector( 0.356793f, -0.491087f, 0.79469f),
        Vector( -0.436878f, -0.601311f, 0.669001f),
        Vector( 0.577307f, -0.187578f, -0.79469f),
        Vector( 0.294237f, -0.705903f, -0.644303f),
        Vector( 0.886927f, -0.45517f, 0.0786233f),
        Vector( -0.559093f, -0.620016f, -0.55045f),
        Vector( -0.885185f, -0.455701f, -0.0937295f),
        Vector( -0.14734f, 0.791177f, 0.593574f),
        Vector( -0.286188f, 0.0929881f, 0.953651f),
        Vector( 0.762277f, 0.061701f, -0.644304f),
        Vector( -0.0000000564056f, 0.607016f, 0.794689f),
        Vector( 0.639174f, -0.114219f, 0.760534f),
        Vector( 0.639173f, 0.11422f, -0.760533f),
        Vector( 0.797984f, 0.104359f, 0.593574f),
        Vector( 0.652962f, 0.398139f, -0.644302f),
        Vector( 0.0000000360737f, -0.987544f, 0.157343f),
        Vector( 0.886927f, 0.45517f, -0.0786233f),
        Vector( -0.577346f, 0.79465f, -0.187625f),
        Vector( 0.983983f, -0.15163f, -0.0937297f),
        Vector( 0.0000000151172f, -0.14951f, -0.98876f),
        Vector( 0.08788f, -0.120956f, 0.98876f),
        Vector( -0.302646f, -0.937435f, 0.172106f),
        Vector( 0.158805f, 0.369797f, 0.91544f),
        Vector( 0.706933f, 0.701043f, -0.0937293f),
        Vector( -0.639194f, 0.629097f, -0.442344f),
        Vector( -0.416907f, 0.815748f, 0.400927f),
        Vector( -0.885164f, 0.287608f, 0.36574f),
        Vector( 0.584244f, -0.55347f, 0.593574f),
        Vector( -0.886893f, -0.133241f, -0.442343f),
        Vector( 0.559094f, -0.620014f, -0.550451f),
        Vector( -0.0000000201564f, 0.951223f, -0.308505f),
        Vector( 0.449996f, 0.889563f, 0.0786233f),
        Vector( 0.158805f, -0.369797f, -0.91544f),
        Vector( 0.0888857f, -0.392517f, 0.91544f),
        Vector( -0.939193f, -0.00423083f, 0.343363f),
        Vector( -0.762439f, -0.340136f, 0.550449f),
        Vector( -0.147346f, 0.884659f, 0.442343f),
        Vector( 0.93921f, 0.305168f, -0.157343f),
        Vector( 0.886893f, -0.133241f, -0.442343f),
        Vector( -0.306164f, 0.936292f, 0.172106f),
        Vector( -0.706933f, -0.701043f, 0.0937293f),
        Vector( 0.547034f, -0.00967021f, -0.837054f),
        Vector( 0.34584f, -0.726681f, 0.593574f),
        Vector( -0.286203f, -0.894533f, 0.343363f),
        Vector( 0.885164f, -0.287608f, -0.36574f),
        Vector( -0.762277f, 0.0617007f, -0.644304f),
        Vector( 0.17824f, -0.517273f, 0.837054f),
        Vector( -0.286203f, 0.894533f, -0.343363f),
        Vector( -0.983983f, -0.15163f, -0.0937293f),
        Vector( 0.286203f, 0.894533f, -0.343363f),
        Vector( -0.580429f, -0.497973f, -0.644302f),
        Vector( -0.76231f, 0.54862f, -0.343364f),
        Vector( -0.81677f, 0.414903f, -0.400927f),
        Vector( 0.345837f, 0.20583f, -0.91544f),
        Vector( 0.302625f, 0.265307f, 0.91544f),
        Vector( -0.356793f, -0.491087f, 0.79469f),
        Vector( -0.885185f, 0.455701f, 0.0937298f),
        Vector( -0.81677f, -0.414903f, 0.400927f),
        Vector( 0.904666f, -0.293944f, 0.308505f),
        Vector( -0.93921f, -0.305168f, 0.157343f),
        Vector( 0.81677f, 0.414903f, -0.400927f),
        Vector( 0.14734f, -0.791177f, -0.593574f),
        Vector( 0.0888863f, -0.643186f, 0.760533f),
        Vector( 0.798031f, 0.577517f, -0.172107f),
        Vector( 0.795857f, -0.58051f, -0.172107f),
        Vector( -0.985081f, 0.153081f, -0.0786234f),
        Vector( -0.580463f, 0.79894f, 0.157343f),
        Vector( 0.449966f, -0.468103f, -0.760533f),
        Vector( -0.0888863f, 0.643186f, -0.760533f),
        Vector( -0.416907f, -0.815748f, -0.400927f),
        Vector( 0.985081f, 0.153081f, -0.0786234f),
        Vector( 0.939193f, -0.0042307f, 0.343363f),
        Vector( 0.176875f, 0.744036f, -0.644303f),
        Vector( -0.356793f, 0.491087f, -0.79469f),
        Vector( 0.448277f, -0.888967f, 0.0937297f),
        Vector( -0.762277f, -0.061701f, 0.644304f),
        Vector( 0.64699f, 0.648584f, 0.400927f),
        Vector( 0.000000056406f, -0.982241f, -0.187625f),
        Vector( 0.416907f, 0.815748f, 0.400927f),
        Vector( 0.147346f, -0.884659f, -0.442343f),
        Vector( 0.400783f, 0.802313f, -0.442343f),
        Vector( 0.885185f, 0.455701f, 0.0937295f),
        Vector( 0.294237f, 0.705903f, 0.644303f),
        Vector( 0.0000000641761f, -0.743261f, -0.669001f),
        Vector( -0.795857f, 0.58051f, 0.172107f),
        Vector( -0.816753f, -0.172975f, 0.55045f),
        Vector( -0.448244f, 0.313715f, 0.837054f),
        Vector( -0.158805f, -0.369797f, -0.91544f),
        Vector( 0.639194f, -0.629097f, 0.442344f),
        Vector( 0.306164f, 0.936292f, 0.172106f),
        Vector( 0.356793f, 0.491087f, -0.79469f),
        Vector( -0.436878f, 0.601311f, -0.669001f),
        Vector( 0.985077f, -0.00184962f, 0.172107f),
        Vector( 0.286188f, -0.0929881f, -0.953651f),
        Vector( -0.886893f, 0.133241f, 0.442343f),
        Vector( 0.547034f, 0.00967031f, 0.837054f),
        Vector( 0.577346f, 0.79465f, -0.187625f),
        Vector( 0.158818f, 0.984172f, -0.0786233f),
        Vector( -0.29425f, 0.891919f, 0.343363f),
        Vector( -0.795829f, 0.413509f, 0.442343f),
        Vector( -0.904654f, 0.144423f, -0.400927f),
        Vector( -0.159846f, -0.52325f, -0.837054f),
        Vector( -0.448277f, 0.888967f, -0.0937297f),
        Vector( 0.0000000310314f, -0.300916f, -0.953651f),
        Vector( 0.0888863f, 0.643186f, -0.760533f),
        Vector( -0.54706f, -0.752967f, 0.36574f),
        Vector( -0.904667f, -0.293944f, 0.308505f),
        Vector( 0.639194f, 0.629097f, -0.442344f),
        Vector( -0.4169f, -0.723326f, -0.550449f),
        Vector( -0.449996f, 0.889563f, 0.0786233f),
        Vector( 0.302646f, -0.937435f, 0.172106f),
        Vector( 0.436877f, 0.329362f, -0.837054f),
        Vector( 0.76231f, 0.54862f, -0.343364f),
        Vector( 0.306145f, -0.572594f, -0.760534f),
        Vector( 0.08788f, 0.120956f, -0.98876f),
        Vector( -0.795857f, -0.58051f, -0.172107f),
        Vector( -0.34584f, 0.726681f, -0.593574f),
        Vector( -0.142193f, -0.0462013f, -0.98876f),
        Vector( 0.176874f, 0.243446f, -0.953651f),
        Vector( 0.306145f, 0.572594f, 0.760534f),
        Vector( 0.934166f, -0.303529f, -0.187625f),
        Vector( 0.706884f, -0.229681f, -0.669001f),
        Vector( -0.087881f, 0.83023f, -0.55045f),
        Vector( 0.762277f, -0.0617007f, 0.644304f),
        Vector( 0.448244f, 0.313715f, 0.837054f),
        Vector( 0.886893f, 0.133241f, 0.442343f),
        Vector( -0.306164f, -0.936292f, -0.172106f),
        Vector( 0.176875f, -0.744036f, 0.644303f),
        Vector( 0.93921f, -0.305168f, 0.157343f),
        Vector( -0.577307f, -0.187578f, -0.79469f),
        Vector( -0.142199f, -0.905007f, 0.400927f),
        Vector( -0.306145f, 0.572594f, 0.760534f),
        Vector( 0.885164f, 0.287608f, 0.36574f),
        Vector( -0.158818f, 0.984172f, -0.0786233f),
        Vector( -0.706933f, 0.701043f, -0.0937296f),
        Vector( -0.306145f, -0.572594f, -0.760534f),
        Vector( 0.757336f, -0.555467f, -0.343363f),
        Vector( -0.142199f, 0.905007f, -0.400927f),
        Vector( 0.29425f, -0.891919f, -0.343363f),
        Vector( 0.302625f, -0.265306f, -0.91544f),
        Vector( -0.286188f, -0.0929884f, -0.953651f),
        Vector( 0.302646f, 0.937435f, -0.172106f),
        Vector( -0.577307f, 0.187578f, 0.79469f),
        Vector( 0.159846f, -0.52325f, -0.837054f),
        Vector( 0.0000000201564f, -0.951223f, 0.308505f),
        Vector( -0.934166f, -0.303529f, -0.187625f),
        Vector( -0.706968f, -0.702862f, -0.0786235f),
        Vector( -0.158805f, 0.369797f, 0.91544f),
        Vector( 0.939193f, 0.00423083f, -0.343363f),
        Vector( -0.706884f, 0.229681f, 0.669001f),
        Vector( -0.797984f, -0.104359f, -0.593574f),
        Vector( -0.400783f, -0.802313f, 0.442343f),
        Vector( -0.302625f, 0.265306f, 0.91544f),
        Vector( -0.142193f, 0.0462013f, 0.98876f),
        Vector( -0.400783f, 0.802313f, -0.442343f),
        Vector( -0.29425f, -0.891919f, -0.343363f),
        Vector( -0.652962f, -0.398139f, 0.644302f),
        Vector( -0.17824f, 0.517273f, -0.837054f),
        Vector( -0.885164f, -0.287608f, -0.36574f),
        Vector( 0.762439f, 0.340136f, -0.550449f),
        Vector( -0.904666f, 0.293944f, -0.308505f),
        Vector( -0.64699f, 0.648584f, 0.400927f),
        Vector( -0.559094f, 0.620014f, 0.550451f),
        Vector( 0.286188f, 0.0929884f, 0.953651f),
        Vector( 0.652962f, -0.398139f, 0.644302f),
        Vector( -0.0000000641761f, 0.743261f, 0.669001f),
        Vector( 0.580429f, -0.497973f, -0.644302f),
        Vector( 0.286203f, -0.894533f, 0.343363f),
        Vector( -0.816753f, 0.172975f, -0.55045f),
        Vector( -0.706884f, -0.229681f, -0.669001f),
        Vector( -0.985077f, -0.00184979f, 0.172107f),
        Vector( -0.34584f, -0.726681f, 0.593574f),
        Vector( 0.70697f, -0.70286f, -0.0786233f),
        Vector( -0.58424f, -0.283291f, 0.760533f),
        Vector( -0.757336f, 0.555467f, 0.343363f),
        Vector( -0.400773f, -0.036759f, 0.91544f),
        Vector( -0.449966f, 0.468103f, 0.760533f),
        Vector( 0.798031f, -0.577517f, 0.172107f),
        Vector( 0.816753f, -0.172975f, 0.55045f)
    };

    return dirs[i];
}

